package com.tensquare.user.dao;

import com.tensquare.user.pojo.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface UserDao extends JpaRepository<User,String> {

    //1.根据手机查询用户
    User findByMobile(String mobile);

    //2.更新粉丝数
    @Modifying
    @Query(nativeQuery = true,
    value = "update tb_user set fanscount=fanscount+?2 where id=?1")
    void incfans(String userId, int num);

    //3.更新关注数
    @Modifying
    @Query(nativeQuery = true,
    value = "update tb_user set followcount=followcount+?2 where id=?1")
    void incfollow(String userId, int num);
}
